package cate.game.play.config.buff;

import cate.common.table.fight.buff.row.BuffRow;
import cate.game.attr.FightAttr;
import cate.game.play.buff.BuffEnhanceCfg;
import cate.game.play.buff.BuffParam;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

@NoteClass("buff配置")
public class BuffCfg {

	@NoteField("buff tid")
	public int id;

	@NoteField("buff原始配置")
	public BuffRow row;

	@NoteField("强化效果")
	public BuffEnhance enhance = new BuffEnhance();


	public BuffCfg(BuffRow row) {
		this.id = row.id;
		this.row = row;
	}

	public boolean containTag(String tag) {
		return row.containTag(tag);
	}

	public boolean containTags(List<String> tags) {
		return row.containTags(tags);
	}

	public boolean isEffectType(String effectType){
		return StringUtils.equals(row.effectType, effectType);
	}

	public void handleEnhanceCfg(BuffEnhanceCfg cfg){
		enhance.handleCfg(cfg);
	}

	public void handleParam(BuffParam param){
		enhance.handleParam(param);
	}

	public int getExAddChance(){
		return enhance.exAddChance;
	}

	public int getLastRound() {
		if (row.lastRound < 0) {
			return -1;
		}
		return enhance.exRound + row.lastRound;
	}

	public FightAttr getExAttr() {
		FightAttr attr = new FightAttr();
		if (StringUtils.isNotBlank(row.attrCode)) {
			attr.add(new FightAttr(row.attrCode));
		}
		attr.add(enhance.exAttr);
		return attr;
	}

	public boolean dispelAble(){
		return enhance.dispel == null ? row.dispel : enhance.dispel;
	}

	public boolean ignAntiCtrl() {
		if (enhance.ignAntiCtrl == null) {
			return false;
		}
		return enhance.ignAntiCtrl;
	}

	public long getBuffHp(){
		return enhance.buffHp;
	}

	public int getPileMax() {
		if (row.pileMax < 0) {
			return -1;
		}
		return enhance.exPileMax + row.pileMax;
	}

	public List<String> getExEffectArgs(){
		return enhance.exEffectArgs;
	}

	public List<ExBuffCfg> getExBuffs(){
		return enhance.exBuffs;
	}
}
